<template>
	<view class="">
		<view class="allbanner" style="position: relative;">
			<view class="bannercenter flexcolumn">
				<view class="bannerimgtext">
					<image src="@/static/image/system/f7xn.png" mode="" class=""></image>
				</view>
				<view class="bannertext3 margin_top">我的法务</view>
			</view>
			<image :src="topimg" mode=""></image>
		</view>
		<view class="mainpadding" style="padding-bottom: 150rpx;" v-if="is_login">
			<view class="flexleft" v-if="userInfo.kf_tel">
				<view class="titletext margin_right2">专属客服</view>
				<view class="notitletext" @click="phone(userInfo.kf_tel)">{{userInfo.kf_name}}:{{userInfo.kf_tel}}
				</view>
			</view>
			<view class="flexleft" v-else>
				<view class="titletext margin_right2">客服</view>
				<view class="notitletext" @click="phone(systeminfo.fhy_kftel)">{{systeminfo.fhy_kfname}}:{{systeminfo.fhy_kftel}}
				</view>
			</view>
			<view class="margin_top">
				<view class="titletext bold hei_text">问题引导：</view>
				<view class="margin_top">
					<text class="dianhei"></text>
					<text class="main_size bold hei_text">员工主动要求不交社保，对企业有没有影响？</text>
				</view>
				<view  class="margin_top">
					<text class="dianlan"></text>
					<text class="main_size bold lan_text">餐费发票抵扣多少的成本？</text>
				</view>
				<view class="margin_top">
					<text class="dianhei"></text>
					<text class="main_size bold hei_text">需要个商标品牌怎么解决？</text>
				</view>
				<view  class="margin_top">
					<text class="dianlan"></text>
					<text class="main_size bold lan_text">公司申请质量体系认证需要哪些资质和要求？</text>
				</view>
				<view class="margin_top">
					<text class="dianhei"></text>
					<text class="main_size bold hei_text">发生交通事故能争取到哪些赔偿？</text>
				</view>
				<view  class="margin_top">
					<text class="dianlan"></text>
					<text class="main_size bold lan_text">小微企业采用合伙制还是公司制更科学？</text>
				</view>
				<view class="margin_top">
					<text class="dianhei"></text>
					<text class="main_size bold hei_text">公司认缴资金和实缴资金有区别吗？</text>
				</view>
			</view>
			<view class="margin_top" v-for="(item,index) in list.data" :key="item.id">
				<view class="" @click="huifu(item)">
					<view class="main_size" style="font-weight: bold;">{{index+1}}.{{item.content}}</view>
					<view class="nostrongtext margin_top">{{item.createtime_text}}</view>
				</view>
				<!-- <view class="flexleft margin_top2">
						<view class="touxiang margin_right1">
							<image src="../../static/image/system/sb.png" mode=""></image>
						</view>
						<view class="nostrongtext">XXX专业律师解答</view>
					</view> -->
				<view class="mainpadding block margin_top" v-for="(ite,index) in item.reply" :key="ite.id"
					v-if="!item.isload && (index==0||index==1||index==2||index==3||index==4)">
					<view class="nostrongtext">{{ite.type==1?"律师：":"我："}}{{ite.content}}</view>
				</view>
				<view class="mainpadding block margin_top" v-for="(ite,index) in item.reply" :key="ite.id"
					v-if="item.isload">
					<view class="nostrongtext">{{ite.type==1?"律师：":"我："}}{{ite.content}}</view>
				</view>
				<view class="flexcenter nostrongtext margin_top" @click="lookall(item)" v-if="item.reply.length>5 && !item.isload">查看更多</view>
				<view class="flexcenter nostrongtext margin_top" @click="shouqiall(item)" v-if="item.isload">收起</view>
			</view>
		</view>
		<view class="flexcenter ffffff mainpadding gudingdb" @click="tzlyd" v-if="is_login">
			<view class="baibtn">我要提问</view>
		</view>
		<u-modal :show="popshow" title="回复" closeOnClickOverlay @close="cancelhuifu" @confirm="surehuifu" showConfirmButton @cancel="cancelhuifu">
			<view class="slot-content">
				<view class="margin_top6">
					<input type="text" style="width: 500rpx;" placeholder="请输入回复内容" v-model="content">
				</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				popshow: false,
				topimg: "",
				content: "",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				currentitem: {},
				userInfo: {},
				is_login:false,
				systeminfo:"",
			}
		},
		onShareAppMessage: function(options) {
			return {
				title: '维瀚法律',
				imageUrl: '',
				path: '/pages/index/index'
			}
		},
		onShareTimeline: function() {
			return {
				title: '维瀚法律',
				imageUrl: '',
				path: '/pages/index/index'
			}
		},
		onLoad() {
			this.getbanner()
		},
		onShow() {
			this.is_login = httpRequest.checkIsLogin();
			if (this.is_login) {
				this.user()
				this.system()
				this.init()
			}
		},
		methods: {
			system(){
				httpRequest.request('/api/index/getConfigInfo','GET',{}).then(res => {
					this.systeminfo = res.data
				})
			},
			lookall(item){
				item.isload = true
			},
			shouqiall(item){
				item.isload = false
			},
			phone(p) {
				uni.makePhoneCall({
					phoneNumber: p.toString()
				}).catch((e) => {
					// console.log(e)  //用catch(e)来捕获错误{makePhoneCall:fail cancel}
				})
			},
			user() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			huifu(item) {
				this.currentitem = item
				this.popshow = true
			},
			surehuifu() {
				if(this.content==""){
					httpRequest.toast("回复内容不能为空！")
					return false
				}
				this.popshow = false
				httpRequest.request('/api/user/replyZyzx', 'POST', {
					zyzx_id: this.currentitem.id,
					content: this.content
				}, false, false, true).then(res => {
					this.content = ""
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						this.init()
					}
				})
			},
			cancelhuifu() {
				this.popshow = false
				this.content = ""
			},
			getbanner() {
				httpRequest.request('/api/index/getAdvertiseList', 'POST', {
					advertise_position_id: 26,
					is_more: 2
				}, false, false, true).then(res => {
					this.topimg = res.data.image_text
				})
			},
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/api/user/getZyzxIndex', 'GET', {
					page: page || 1,
					limit: _this.limit,
				}, false, false, true).then(res => {
					res.data.data.forEach(item=>{
						this.$set(item,"isload",false)
					})
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// 跳转留言单
			tzlyd() {
				uni.navigateTo({
					url: '/pages/wodefw/liuyandan'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.dianhei{
		display: inline-block;
		width: 20rpx;
		height: 20rpx;
		border-radius: 50rpx;
		border: 2rpx solid #333;
		margin-right: 10rpx;
	}
	.dianlan{
		display: inline-block;
		width: 20rpx;
		height: 20rpx;
		border-radius: 50rpx;
		border: 2rpx solid #9e8d5e;
		margin-right: 10rpx;
	}
	.lan_text{
		color: #9e8d5e;
	}
	.baibtn {
		width: 200rpx;
		height: 60rpx;
		background-color: #9e8d5e;
		color: #ffffff;
		font-size: 28rpx;
		font-weight: 500;
		display: flex;
		border-radius: 36rpx;
		align-items: center;
		justify-content: center;
	}

	.block {
		border: 2rpx solid #f5f5ff;
	}

	.touxiang {
		width: 70rpx;
		height: 70rpx;
		border-radius: 50%;

		image {
			border-radius: 50%;
			width: 100%;
			height: 100%;
		}
	}
</style>